﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace FilStartUps_Mobile.Models
{
    public class FilStartUpsEntities : DbContext
    {
        public FilStartUpsEntities() :
            base("FILSTARTUPS")
        {
            Database.SetInitializer<FilStartUpsEntities>(null);
        }

        public DbSet<Member> Members { get; set; }
       // public DbSet<Comment> Comments { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Profile> Profiles { get; set; }
        public DbSet<ForumGroup> ForumGroups { get; set; }
        public DbSet<Forum> Forums { get; set; }
        public DbSet<ForumThread> ForumThreads { get; set; }
        public DbSet<ForumMessage> ForumMessages { get; set; }
        public DbSet<ForumReport> ForumReports { get; set; }
        public DbSet<Session> Sessions { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            //modelBuilder.Entity<Comment>().ToTable("dbo.Comment");
            //modelBuilder.Entity<Comment>().Property(c => c.commentidPK);

            modelBuilder.Entity<Member>().ToTable("dbo.Member");
            modelBuilder.Entity<Member>().Property(m => m.memberidPK);

            modelBuilder.Entity<Profile>().ToTable("dbo.Profile");
            modelBuilder.Entity<Profile>().Property(p => p.profileidPK);

            modelBuilder.Entity<Role>().ToTable("dbo.Role");
            modelBuilder.Entity<Role>().Property(r => r.roleidPK);

            modelBuilder.Entity<ForumThread>().ToTable("dbo.ForumThread");
            modelBuilder.Entity<ForumThread>().Property(ft => ft.forumthreadidPK);


            modelBuilder.Entity<ForumReport>().ToTable("dbo.ForumReport");
            modelBuilder.Entity<ForumReport>().Property(frep => frep.forumreportidPK);

            modelBuilder.Entity<ForumGroup>().ToTable("dbo.ForumGroup");
            modelBuilder.Entity<ForumGroup>().Property(fg => fg.forumgroupidPK);

            modelBuilder.Entity<Session>().ToTable("dbo.Session");
            modelBuilder.Entity<Session>().Property(s => s.sessionidPK);


            modelBuilder.Entity<Forum>().ToTable("dbo.Forum");
            modelBuilder.Entity<Forum>().Property(f => f.forumidPK);

            modelBuilder.Entity<ForumMessage>().ToTable("dbo.ForumMessage");
            modelBuilder.Entity<ForumMessage>().Property(fm => fm.forummsgidPK);

            //modelBuilder.Entity<Session>().HasKey(s => s.sessionidPK);
            //modelBuilder.Entity<Comment>().HasKey(c => c.commentidPK);
            //modelBuilder.Entity<Member>().HasKey(m => m.memberidPK);
            //modelBuilder.Entity<Role>().HasKey(r => r.roleidPK);
            //modelBuilder.Entity<Profile>().HasKey(p => p.profileidPK);
            //modelBuilder.Entity<Forum>().HasKey(f => f.forumidPK);
            //modelBuilder.Entity<ForumGroup>().HasKey(fg => fg.forumgroupidPK);
            //modelBuilder.Entity<ForumMessage>().HasKey(fm => fm.forummsgidPK);
            // modelBuilder.Entity<ForumReply>().HasKey(f => f.forumreplyidPK);
            //modelBuilder.Entity<ForumThread>().HasKey(ft => ft.forumthreadidPK);    
            //modelBuilder.Entity<ForumReport>().HasKey(fr => fr.forumreportidPK);
        }
    }

}